package com.hz.web.controller;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.hz.web.entity.TpEntity;
import com.hz.web.service.ItpService;

@Controller
@RequestMapping("tp")
public class TpController {

	@Resource
	private ItpService tpService;
	
	/**
	 * 添加民意调查数据
	 * @param entity
	 * @return
	 */
	@RequestMapping("addTp")
	@ResponseBody
	public Map<String, Object> addTp(HttpServletRequest request,TpEntity entity){
		Map<String, Object> resultMap = new HashMap<String, Object>();
		int row = tpService.addTp(request,entity);
		resultMap.put("row", row);
		return resultMap;
	}
	/**
	 * 
	 * 查询民意调查的4列的数值
	 * @return
	 */
	@RequestMapping("getTpData")
	public String getTpData(Model model,HttpServletRequest request,
			HttpServletResponse response){
		
		Map<String, Object> parmsMap = new HashMap<String, Object>();
		List<Object> list = new ArrayList<Object>();	
		parmsMap.put("typeId", "1");//1是能对自然人进行信用评价
		int column1 = tpService.queryCountByTypeId(parmsMap);
		parmsMap.put("typeId", "2");//2能对企业进行信用评价
		int column2 = tpService.queryCountByTypeId(parmsMap);
		parmsMap.put("typeId", "3");//3能对自然人和企业进行信用评价
		int column3 = tpService.queryCountByTypeId(parmsMap);
		parmsMap.put("typeId", "4");//4不合适，应由第三方机构进行评价
		int column4 = tpService.queryCountByTypeId(parmsMap);
		list.add(column1);
		list.add(column2);
		list.add(column3);
		list.add(column4);
		request.setAttribute("list", list);
		return "column_chart_xml";
	}
	
	
	
	
	
	
	
	
	
	
	
}
